package org.tacademy.and12.mesapp;

import java.util.ArrayList;

import android.content.Context;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.LinearLayout;
import android.widget.TextView;

public class MyAdapterMaster extends ArrayAdapter<MyDataMaster> {
	ArrayList<MyDataMaster> mList;
	Context mContext;
	TextView code;
	TextView name;
	TextView worker;
	TextView workDate;

	public MyAdapterMaster(Context context, ArrayList<MyDataMaster> list) {
		super(context,0, list);
		mList = list;
		mContext = context;
	}
	

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		// TODO Auto-generated method stub
		LinearLayout layoutMyData;
		
		if(convertView == null){
			LayoutInflater inflater = LayoutInflater.from(mContext);
			layoutMyData = (LinearLayout)inflater.inflate(R.layout.fragment_master_reg_sublayout, null);
		}else{
			layoutMyData = (LinearLayout)convertView;
		}
		
		code = (TextView)layoutMyData.findViewById(R.id.txtCode);
		name = (TextView)layoutMyData.findViewById(R.id.txtName);
		worker = (TextView)layoutMyData.findViewById(R.id.txtWorker);
		workDate = (TextView)layoutMyData.findViewById(R.id.txtWorkDate);
		
		MyDataMaster currentData = mList.get(position);
		
		code.setText(currentData.code);
		name.setText(currentData.name);
		worker.setText(currentData.worker);
		workDate.setText(currentData.workDate);		
			
		return (View)layoutMyData;
	}

}
